package doj;

import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import org.junit.Test;

/**
 * Tests to make sure PointBearing is sensible results.
 * @author Jordan Do
 *
 */
public class TestPointBearing {
  
  DojBot tester = new DojBot();
  
  /**
   * Tests to make sure its what it should be in certain quadrants.
   */
  @Test
  public void testPointBearing() {
    //quadrant 1
    //on same x it's 0
    assertEquals(tester.pointBearing(0, 0, 0, 5), 0, 0);
    //on same y  it's 270
    assertEquals(tester.pointBearing(0, 0, -5, 0), 270, 0);
    //between 270 and 360 (including 0)
    for (int i = 0; i > -10; i--) {
      for (int k = 0; k < 10; k++) {
        Boolean withinBounds = true;
        if (tester.pointBearing(0, 0, i, k) < 270) {
          withinBounds = false;
        }
        if (tester.pointBearing(0, 0, i, k) > 360) {
          withinBounds = false;
        }
        if (tester.pointBearing(0, 0, i, k) == 0) {
          withinBounds = true;
        }
        assertTrue("Between 270 and 360", withinBounds); 
      }
    }
    //quadrant 2
    //on same x it's 0
    assertEquals(tester.pointBearing(0, 0, 0, 5), 0, 0);
    //on same y  it's 90
    assertEquals(tester.pointBearing(0, 0, 5, 0), 90, 0);
    //between 0 and 90
    for (int i = 0; i < 10; i++) {
      for (int k = 0; k < 10; k++) {
        Boolean withinBounds = true;
        if (tester.pointBearing(0, 0, i, k) < 0) {
          withinBounds = false;
        }
        if (tester.pointBearing(0, 0, i, k) > 90) {
          withinBounds = false;
        }
        assertTrue("Between 0 and 90", withinBounds); 
      }
    }
  }
}
